﻿@{
    ViewBag.Title = "Resultado de busqueda";

    Layout = (ViewBag.esCliente!=null && ViewBag.esCliente?"~/Views/Shared/_ClienteLayout.cshtml":"~/Views/Shared/_Layout.cshtml");
}
@using equinoxWeb.Models;
<script src="/Scripts/tarea.js"></script>

<!-- content -->

<fieldset style="width: inherit">
    <legend>Lista de tareas:</legend>
</fieldset>

<form class="form-horizontal" name="MisTareasForm" action="/Tarea/ListarTareasCaso" method="get">
    <input type="hidden" id="accionOrigen" name="accionOrigen" />
    <input type="hidden" id="idTarea" name="idTarea" />
    <input type="hidden" id="idCaso" name="idCaso" value="@ViewBag.idCaso"/>
    <table class="table table-hover"> 
        <tr>
            <th>Caso</th>
            <th>Fecha creacion</th>
            <th>Fecha inicio</th>
            <th>Fecha vencimiento</th>
            <th>Encargado</th>
            <th>Descripcion</th>
            <th>Estado</th>
            <th></th>
        </tr>
        @foreach (Tarea tarea in ViewBag.tareasPendientes)
        {
            <tr>
                <td><a href="/caso/details?idCaso=@tarea.IdCaso">@tarea.ReferenciaCaso </a></td>
                <td>@tarea.FechaCreacion </td>
                <td>@tarea.FechaInicio </td>
                <td>@tarea.FechaFinProgramada </td>
                <td>@tarea.NombreUsuario </td>
                <td>@tarea.Descripcion </td>
                <td>@tarea.EstadoTarea.Descripcion @((tarea.EstadoTarea.IdEstadoTarea == Constantes.EstadoTareaFinalizada)?" el " + tarea.FechaFin:"") </td>
                <td>
                    <input type="hidden" value="@tarea.IdTarea" class="tarea" />
                    <input type="hidden" value="@tarea.IdCaso" class="caso" />
                    @if (tarea.EstadoTarea.IdEstadoTarea == Constantes.EstadoTareaPendiente)
                    {
                        <a style="vertical-align: top" href="#" onclick="javascript:atenderTarea(document.MisTareasForm,this)">
                            <span style="vertical-align: central; line-height: 100%;" class="glyphicon glyphicon-check"></span>
                        </a>
                    }
                    else if (tarea.EstadoTarea.IdEstadoTarea == Constantes.EstadoTareaEnProgreso)
                    {
                        <a style="vertical-align: top" href="#" onclick="javascript:finalizarTarea(document.MisTareasForm,this)">
                            <span style="vertical-align: central; line-height: 100%;" class="glyphicon glyphicon-check"></span>
                        </a>  
                    }
                </td>
            </tr>
        }
    </table>
    <div class="form-group">
            <div class="col-md-3 col-sm-6">
                <button type="button" class="btn btn-large btn-primary" onclick="javascript:AgregarTarea(document.MisTareasForm);">Agregar tarea</button>&nbsp;
                <button type="button" class="btn btn-large" onclick="javascript:AbrirCaso(document.MisTareasForm);">Atras</button>
            </div>
        </div>
</form>
